<extend name="./Apps/Home/View/default/shops/layout.html" />
<block name="content">

    <script src="__PUBLIC__/plugins/kindeditor/kindeditor.js"></script>
    <script src="__PUBLIC__/plugins/kindeditor/lang/zh-CN.js"></script>

    <script src="__PUBLIC__/jquery-ui/jquery-ui-1.10.4.custom.min.js"></script>

    <link rel="stylesheet" type="text/css" href="__PUBLIC__/plugins/webuploader/style.css" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/jquery-ui/css/base/jquery-ui-1.10.4.custom.min.css" />
    <script>
        var ablumInit = false;
        $(function () {

            initTime('useTimeStart','{$object.useTimeStart}');
            initTime('useTimeEnd','{$object.useTimeEnd}');

            $("#periodStart").datepicker({
                showButtonPanel:false,
                monthNames: ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'],
                dayNamesMin: ['日','一','二','三','四','五','六'],
                prevText: '<上月',
                nextText: '下月>',
                currentText: '今天',
                dateFormat: 'yy-mm-dd'

            });
            $("#periodEnd").datepicker({
                showButtonPanel:false,
                monthNames: ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'],
                dayNamesMin: ['日','一','二','三','四','五','六'],
                prevText: '<上月',
                nextText: '下月>',
                currentText: '今天',
                dateFormat: 'yy-mm-dd'
            });

            $('#tab').TabPanel({tab:0,callback:function(no){
                if(no==1 && !ablumInit)uploadAblumInit();
            }});
            $.formValidator.initConfig({
                theme:'Default',mode:'AutoTip',formID:"myform",debug:true,submitOnce:true,onSuccess:function(){
                    editGoods('{$umark}');
                    return false;
                },onError:function(msg){
                }});
            $("#goodsSn").formValidator({onShow:"",onFocus:"",onCorrect:"输入正确"}).inputValidator({min:1,max:50,onError:"请输入包厢编号"});
            $("#goodsName").formValidator({onShow:"",onFocus:"",onCorrect:"输入正确"}).inputValidator({min:1,max:200,onError:"请输入包厢名称"});
           // $("#marketPrice").formValidator({onShow:"",onFocus:"",onCorrect:"输入正确"}).inputValidator({min:1,max:50,onError:"请输入市场价格"});
            $("#shopPrice").formValidator({onShow:"",onFocus:"",onCorrect:"输入正确"}).inputValidator({min:1,max:50,onError:"请输入包厢价格"});
           // $("#goodsStock").formValidator({onShow:"",onFocus:"",onCorrect:"输入正确"}).inputValidator({min:1,max:50,onError:"请输入库存"});
           // $("#goodsUnit").formValidator({onShow:"",onFocus:"",onCorrect:"输入正确"}).inputValidator({min:1,max:50,onError:"请输入包厢单位"});
            //$("#goodsCatId3").formValidator({onFocus:"请选择商城分类"}).inputValidator({min:1,onError: "请选择完整商城分类"});
          //  $("#shopCatId2").formValidator({onFocus:"请选择本店分类"}).inputValidator({min:1,onError: "请选择完整本店分类"});

            KindEditor.ready(function(K) {
                editor1 = K.create('textarea[name="useRule"]', {
                    height:'250px',
                    width:"800px",
                    allowFileManager : false,
                    allowImageUpload : true,
                    items:[
                        'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'cut', 'copy', 'paste',
                        'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
                        'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
                        'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
                        'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
                        'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|','image','multiimage','table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
                        'anchor', 'link', 'unlink', '|', 'about'
                    ],
                    afterBlur: function(){ this.sync(); }
                });

            });
        var uploading = null;
        uploadFile({
            server:Think.U('Home/Goods/uploadPic'),pick:'#goodImgPicker',
            formData: {dir:'goods'},
            accept: {
                title: 'Images',
                extensions: 'gif,jpg,jpeg,png',
                mimeTypes: 'image/*'
            },
            callback:function(f){
                layer.close(uploading);
                var json = WST.toJson(f);
                $('#goodsImgPreview').attr('src',WST.DOMAIN+"/"+json.file.savepath+json.file.savethumbname);
                $('#goodsImg').val(json.file.savepath+json.file.savename);
                $('#goodsThums').val(json.file.savepath+json.file.savethumbname);
                $('#goodsImgPreview').show();
            },
            progress:function(rate){
                uploading = WST.msg('正在上传图片，请稍后...');
            }
        });
        $('input[name="isDistribut"]').click(function(){
            if($(this).val()==1){
                $(".commission_tr").show();
            }else{
                $(".commission_tr").hide();
            }
        });
        });

        function imglimouseover(obj){
            if(!$(obj).find('.file-panel').html()){
                $(obj).find('.setdel').addClass('trconb');
                $(obj).find('.setdel').css({"display":""});
            }
        }

        function imglimouseout(obj){

            $(obj).find('.setdel').removeClass('trconb');
            $(obj).find('.setdel').css({"display":"none"});
        }

        function imglidel(obj){
            if (confirm('是否删除图片?')) {
                $(obj).parent().remove("li");
                return;
            }
        }

        function imgmouseover(obj){
            $(obj).find('.wst-gallery-goods-del').show();
        }
        function imgmouseout(obj){
            $(obj).find('.wst-gallery-goods-del').hide();
        }
        function delImg(obj){
            $(obj).parent().remove();
        }
    </script>
    <div class="wst-body">
        <div class='wst-page-header'>商家中心 > <if condition="$object['goodsId'] ==0 ">新增<else/>编辑</if>包厢资料</div>
        <div class='wst-page-content'>
            <div id='tab' class="wst-tab-box">
                <ul class="wst-tab-nav">
                    <li>包厢信息</li>

                </ul>
                <div class="wst-tab-content" style='width:99%;margin-bottom: 10px;'>


                    <!-- 包厢基础信息 -->
                    <div class='wst-tab-item' style="position: relative;style='display:none'">
                        <form name="myform" method="post" id="myform" autocomplete="off">
                            <input type='hidden' id='id' class='wstipt' value='{$object.goodsId}'/>

                            <input type='hidden' id='goodsThumbs' value='{$object.goodsThums}'/>
                            <table class="wst-form" >
                                <tr>
                                    <th width='120'>包厢编号<font color='red'>*</font>：</th>
                                    <td width='400'>
                                        <input type='text' id='goodsSn' name='goodsSn' class="wst-ipt wstipt" value='{$object.goodsSn}' maxLength='25'/>
                                    </td>
                                    <td rowspan='6' valign='top'>
                                        <div>
                                            <img id='goodsImgPreview' class='lazyImg' data-original='<if condition="$object['goodsImg'] =='' ">__ROOT__/{$CONF['goodsImg']}<else/>__ROOT__/{$object['goodsImg']}</if>' style="height:100px;width:150px;"/><br/>
                                        </div>
                                        <input type='hidden' id='goodsImg' class='wstipt' value='{$object.goodsImg}'/>
                                        <input type='hidden' id='goodsThums' class='wstipt' value='{$object.goodsThums}'/>
                                        <div id="goodImgPicker" style='margin-left:0px;margin-top:5px;height:30px;overflow:hidden;width:100px;'>上传包厢图片</div>
                                        <div>图片大小:150 x 150 (px)，格式为 gif, jpg, jpeg, png</div>
                                    </td>
                                </tr>
                                <tr>
                                    <th width='120'>包厢名称<font color='red'>*</font>：</th>
                                    <td><input type='text' id='goodsName' name='goodsName' class="wst-ipt wstipt" value='{$object.goodsName}' maxLength='100'/></td>
                                </tr>

                                <tr>
                                    <th width='120'>包厢价格<font color='red'>*</font>：</th>
                                    <td>
                                        <if condition="$object.recommPrice gt 0">
                                            <input type='text' id='shopPrice' name='shopPrice' disabled="disabled" class="wstipt wst-ipt" value='{$object.recommPrice}' onkeypress="return WST.isNumberdoteKey(event)" onkeyup="javascript:WST.isChinese(this,1)" maxLength='10'/>
                                            <else/>
                                            <input type='text' id='shopPrice' name='shopPrice' class="wstipt wst-ipt" value='{$object.shopPrice}' onkeypress="return WST.isNumberdoteKey(event)" onkeyup="javascript:WST.isChinese(this,1)" maxLength='10'/>
                                        </if>

                                    </td>
                                </tr>

                                <tr>
                                    <th width='120'>包厢大小<font color='red'>*</font>：</th>
                                    <td><input type='text' id='size' name='size' class="wst-ipt wstipt" value='{$object.size}'    maxLength='100'/></td>
                                </tr>

                                <tr>
                                    <th width='120'>有效期<font color='red'>*</font>：</th>
                                    <td><input type='text' id='periodStart' name='periodStart' class="wst-ipt wstipt"   readonly="readonly" value="{$object.periodStart}"/>-
                                    <input type='text' id='periodEnd' name='periodEnd' class="wst-ipt wstipt"   readonly="readonly" value="{$object.periodEnd}"/></td>
                                </tr>

                                <tr>
                                    <th width='120'>使用时间<font color='red'>*</font>：</th>
                                    <td><select  id='useTimeStart' name='useTimeStart' class="wst-ipt wstipt" ></select> -
                                    <select id='useTimeEnd' name='useTimeEnd' class="wst-ipt wstipt"   ></select></td>
                                </tr>

                                <tr>
                                    <th width='120'>使用规则<font color='red'>*</font>：</th>
                                    <td colspan='3'>
                                        <textarea rows="2" cols="60" id='useRule' class='wstipt' name='useRule'>{$object.useRule}</textarea>
                                    </td>
                                </tr>



                                <tr>
                                    <td colspan='3' style='padding-left:320px;'>
                                        <button class='wst-btn-query' type="submit">保&nbsp;存</button>
                                        <if condition="$umark !='toEdit' ">
                                            <button class='wst-btn-query' type="button" onclick='javascript:location.href="{:U('Home/Goods/'.$umark)}"'>返&nbsp;回</button>
                                        </if>
                                    </td>
                                </tr>
                            </table>
                        </form>
                    </div>



                </div>
            </div>

        </div>
        <div style='clear:both;'></div>
    </div>

</block>